import {getCalendar} from "@/api/calc/otcOption/calc";

const calendar = {
    state: {
        tcalendarDates:[]
    },
    mutations: {
        SET_TradeDates: (state, dates) => {
            state.tcalendarDates = dates
        }
    },
    actions: {
        GetCalendars({ commit }) {
            var Calendars = {};

            getCalendar({}).then(response => {
                    if (response.errorCode != 0) {
                    } else {
                        Calendars.datesArr = response.result.map(item => item.CAL_DAY)
                        Calendars.dates = response.result.map(item => (
                            {
                                date: item.CAL_DAY,
                                flag: 'l'
                            }
                        ))
                        commit('SET_TradeDates', Calendars.datesArr)
                    }
                }
            )
        }
    }
}

export default calendar;
